const { User } = require('../../model/user');
module.exports = async(req, res) => {
    req.app.locals.current = 'user';

    // 分页功能
    let page = req.query.page || 1;
    // 设置分页条数
    let pagesize = 5;
    // 或取用户条数
    let count = await User.countDocuments({});
    // 总页数
    let total = Math.ceil(count / pagesize);
    // 页码对应的数据查询开始位置
    let start = (page - 1) * pagesize
    let use = await User.find({});
    let user = await User.find({}).limit(pagesize).skip(start);
    const countUser = use.length;
    // res.send(user);
    res.render('admin/user', {
        user: user,
        page: page,
        total: total,
        countUser: countUser
    });
};